package com.freemarker.db;

import java.text.SimpleDateFormat;
import java.util.Date;




public class StringUtil {
	
	public static String ymdhm = "yyyy-MM-dd HH:mm";
	
	public static final boolean isEmpty(final String str) {
		if (str == null || str.trim().length() < 1) {
			return true;
		}
		return false;
	}
	
	/**
	 * 判断字符串是否为空，如果不为空返回true，否则返回false
	 * @param s
	 * @return
	 */
	public static final boolean isNotEmpty(final String str) {
		if (str == null || str.trim().length() < 1) {
			return false;
		}
		return true;
	}
	
	/**
	 * 功能说明:去掉字符串2端空格或空白。如果参数字符串为null，那么返回结果为空白字符串，即"";
	 * @param s 需要过滤的字符串
	 * @return
	 */
	public static String trim(Object obj) {
		String tmp = obj == null ? "" : obj.toString().trim();
		if ("null".equalsIgnoreCase(tmp)) {
			return "";
		}
		return tmp;
	}
	
	public static String getTableToClazzName(String param) {
		String[] array = param.split("_");
		StringBuffer sb = new StringBuffer("");
		for (int i = 0; i < array.length; i++) {
			String str = array[i];
			if (str.length() > 0) {
				if (str.length() == 1) {
					sb.append(str.toUpperCase());
				} else {
					String a = str.substring(0, 1);
					String b = str.substring(1);
					sb.append(a.toUpperCase()).append(b.toLowerCase());
				}
			}
		}
		return sb.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(getDate());
	}

	public static String getDate() {
		SimpleDateFormat sdf = new SimpleDateFormat(ymdhm);
		String date = sdf.format(new Date());
		return date;
	}
	
	public static String getDate(Date date,String fommater) {
		SimpleDateFormat sdf = new SimpleDateFormat(fommater);
		String datestr = sdf.format(new Date());
		return datestr;
	}
}
